$ = jQuery;
jQuery(document).ready(function ($) {
$('.reviews-slider').slick({
infinite: true,
slidesToShow: 2,
slidesToScroll: 1,
dots:false,
arrows:true,
prevArrow: $('.review-prev'),
nextArrow: $('.review-next'),
responsive: [
{
breakpoint: 768,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
},
]
});
/*Currencies*/
var countryCurrencyMapping = {
"GB": "GBP",
"US": "USD",
"AU": "AUD",
"CA": "CAD",
"CN": "CNY",
"DK": "DKK",
"HK": "HKD",
"IS": "ISK",
"IN": "INR",
"JP": "JPY",
"MY": "MYR",
"NO": "NOK",
"PL": "PLN",
"SE": "SEK",
"SG": "SGD",
"ZA": "ZAR",
"CH": "CHF"
// Add more mappings as needed
};
function getUserCountryAndCurrency(callback) {
// Use IPinfo API to get information based on user's IP
var currencyCode = '';
var country = '';
$.get("https://ipinfo.io", function (response) {
// Extract country and currency code from the API response
country = response.country;
currencyCode = getCurrencyCodeByCountry(country);
// Call the callback function with the currencyCode
callback(currencyCode);
}, "jsonp");
}
function getCurrencyCodeByCountry(country) {
// Use the countryCurrencyMapping array to get the currency code
return countryCurrencyMapping[country] || "Unknown";
}
setTimeout(function () {
let $wcml = $('.wcml-dropdown');
if ($wcml.length > 0) {
getUserCountryAndCurrency(function (currentCurrency) {
console.log("Currency Code: " + currentCurrency);
if (currentCurrency !== "Unknown") {
$('.wcml-cs-submenu').prepend($(`a[rel="${currentCurrency}"]`).parent());
$('.wcml-cs-submenu li:nth-child(3)').after('
Other currencies');
} else {
$('.wcml-cs-submenu li:nth-child(2)').after('Other currencies');
}
$('.wcml-cs-submenu').prepend('Popular currencies');
});
/* $('.wcml-cs-active-currency a').each(function () {
let thisRel = $(this).text();
if (thisRel == 'USD - $') {
$(this).prepend('
');
} else if (thisRel == 'GBP - £') {
$(this).prepend('
');
} else if (thisRel == 'EUR - €') {
$(this).prepend('
');
} else if (thisRel == 'AUD - $') {
$(this).prepend('
');
} else if (thisRel == 'CAD - $') {
$(this).prepend('
');
} else if (thisRel == 'CNY - ¥') {
$(this).prepend('
');
} else if (thisRel == 'HKD - $') {
$(this).prepend('
');
} else if (thisRel == 'INR - ₹') {
$(this).prepend('
');
} else if (thisRel == 'JPY - ¥') {
$(this).prepend('
');
} else if (thisRel == 'MYR - RM') {
$(this).prepend('
');
} else if (thisRel == 'CHF - CHF') {
$(this).prepend('
');
} else if (thisRel == 'SGD - $') {
$(this).prepend('
');
} else if (thisRel == 'ZAR - R') {
$(this).prepend('
');
}
});*/
}
}, 1000);
/*Currencies*/
const url = new URL(window.location.href);
let updated = false;
// Check and delete 'add-to-cart' if present
if (url.searchParams.has("add-to-cart")) {
url.searchParams.delete("add-to-cart");
updated = true;
}
// Check and delete 'currency' if present
if (url.searchParams.has("currency")) {
url.searchParams.delete("currency");
updated = true;
}
// Update the browser's address bar without reloading the page
if (updated) {
window.history.replaceState({}, document.title, url.pathname + url.search);
}
$(".policy-wrap h2").each(function () {
let text = $(this).text();
let id = $(this).attr("id");
$("#nav").append(`${text}`);
});
$(document).on("wpcf7mailsent", function (event) {
if (event.detail.contactFormId == "62") {
$("#thanks-popup").addClass("active");
$("#thanks-popup svg").click(function () {
$("#thanks-popup").removeClass("active");
});
}
});
if (window.location.hash) {
// Get the target element
var target = $(window.location.hash);
// Calculate the offset to compensate for the header
var offset = target.offset().top - 200;
console.log(offset);
// Scroll to the target element with the offset
$("html, body").animate(
{
scrollTop: offset,
},
1000
);
}
$("#form-log").validate({
errorContainer: $("body").find(".form-errors"),
errorLabelContainer: $("span", $("body").find(".form-errors")),
groups: {
allItems: "username password",
},
rules: {
username: {
required: true,
},
password: {
required: true,
},
},
});
$.extend($.validator.messages, {
required: "All fields are required!",
});
$('input[type="tel"]').intlTelInput({
autoHideDialCode: false,
separateDialCode: false,
preferredCountries: ["gb", "us"],
customPlaceholder: function (
selectedCountryPlaceholder,
selectedCountryData
) {
return "" + selectedCountryPlaceholder;
},
geoIpLookup: function (callback) {
$.get("https://ipinfo.io", function () {}, "jsonp").always(function (
resp
) {
var countryCode = resp && resp.country ? resp.country : "";
callback(countryCode);
});
},
utilsScript:
"https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/16.0.0/js/utils.js",
});
$(".course-program-title").click(function () {
$(this).siblings(".course-program").slideToggle(500);
});
$(".plus").click(function () {
console.log("click");
$(this).parent().toggleClass("opened");
$(this).parent().find(".info").slideToggle(500);
});
});
document.addEventListener("DOMContentLoaded", function () {
const closeButton = document.querySelector(".close-top-header");
const topHeader = document.querySelector(".top-header");
if (closeButton && topHeader) {
closeButton.addEventListener("click", function () {
topHeader.style.display = "none";
});
}
});